//从插件内导出createRouter、createWebHashHistory
import{createRouter,createWebHashHistory} from "vue-router";

//导入组件
import LoginCom from "@/components/LoginCom.vue";
import HomeCom from "@/components/HomeCom.vue"
import AddPerson from "@/components/AddPerson.vue"
import ListPerson from "@/components/ListPerson.vue"
import SchoolList from "@/components/SchoolList.vue"
import ZhuCom from "@/components/ZhuCom.vue"
import EditPerson from "@/components/EditPerson.vue"
import ProductList from "@/components/ProductList.vue"
import EditProd from "@/components/EditProd.vue"






//定义路由表
const routes =[
    {
        path:'/',
        redirect:'/login'
    },
    {
        path :'/login',
        name : "LoginCom",
        component :LoginCom,
             
    },
    {
        path:'/zhu',
        name:'ZhuCom',
        component:ZhuCom
    },
  
    {
        path :'/home',
        name : "HomeCom",
        component :HomeCom,
        children :[
            //第一个字路由
            {
                path:'add',
                name:'AddPerson',
                component:AddPerson
            },
            //第二个子路由
            {
                path:'per',
                name:'ListPerson',
                component:ListPerson
            },
            {
                path:'school',
                name:'SchoolList',
                component:SchoolList
            },
            {
                path:'edit',
                name:'EditPerson',
                component:EditPerson
            },
            {
                path:'pro',
                name:'ProductList',
                component:ProductList
            },
            {
                path:'edpro',
                name:'EditProd',
                component:EditProd
            },
        ]
    },
   
];

//定义路由器/创建路由器
const router=createRouter({
    //调用路由表，实现router-link的跳转以及router-view的渲染
    // routes : routes,
    routes,
    //将路由历史模式设置为hash模式（哈希历史）
    history :createWebHashHistory(),
});

//导出路由器
export default router;